// Demo数据集中管理文件

export interface Agent {
  id: string;
  agentName: string;
  agentAddress: string;
  description: string;
  authorBio: string;
  agentClassification: string;
  tags: string[];
  isPrivate: boolean;
  autoAcceptJobs: boolean;
  contractType: string;
  isActive: boolean;
  reputation: number;
  successRate: number;
  totalJobsCompleted: number;
  walletAddress: string;
  createdAt: string;
  isFree?: boolean;
  rating?: number;
  reviews?: number;
}

export interface Job {
  id: string;
  jobTitle: string;
  category: string;
  description: string;
  deliverables: string;
  budget: { min: number; max: number } | number;
  maxBudget: number;
  deadline: string;
  paymentType: string;
  priority: string;
  skillLevel: string;
  tags: string[];
  status: 'OPEN' | 'DISTRIBUTED' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED' | 'EXPIRED';
  autoAssign: boolean;
  allowBidding: boolean;
  allowParallelExecution: boolean;
  escrowEnabled: boolean;
  isPublic: boolean;
  walletAddress: string;
  createdAt: string;
  applications?: number;
  assignments?: number;
}

export interface Category {
  id: string;
  title: string;
}

export interface JobDistributionAgent {
  id: string;
  agentId: string;
  agentName: string;
  workStatus: 'ASSIGNED' | 'WORKING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TIMEOUT';
  executionResult: string;
  startedAt: string;
  completedAt: string;
  progress: number;
  errorMessage: string;
  executionTimeMs: number;
  retryCount: number;
  rating?: number;
  successRate?: number;
}

export interface DashboardStats {
  totalAgents: number;
  activeAgents: number;
  totalJobs: number;
  completedJobs: number;
  totalCategories: number;
  totalEarnings: number;
  averageJobCompletionTime: number;
  successRate: number;
  publishedAgents?: number;
  activeContracts?: number;
  inProgressJobs?: number;
  disputes?: number;
}

// Demo Agent数据
export const demoAgents: Agent[] = [
  {
    id: '1',
    agentName: 'PollyArt',
    agentAddress: 'http://localhost:3005/api/pollinations',
    description: 'Generates playful cartoon-style images using Pollinations AI - totally free.',
    authorBio: "I'm an indie dev who loves building quirky little art bots for fun.",
    agentClassification: 'Visual Designer',
    tags: ['Image', 'Fun', 'Visual'],
    isPrivate: false,
    autoAcceptJobs: true,
    contractType: 'result',
    isActive: true,
    reputation: 0,
    successRate: 0,
    totalJobsCompleted: 0,
    walletAddress: '0x1234...5678',
    createdAt: '2024-01-01T00:00:00Z',
    isFree: true,
    rating: 0,
    reviews: 0,
  },
  {
    id: '2',
    agentName: 'DalliCraft',
    agentAddress: 'https://api.example.com/dallicraft',
    description: '专业的数据分析服务，提供数据清洗、分析和可视化',
    authorBio: '统计学博士，10年数据分析经验',
    agentClassification: '数据分析',
    tags: ['数据分析', 'SQL', 'Python', 'Tableau'],
    isPrivate: false,
    autoAcceptJobs: false,
    contractType: 'hourly',
    isActive: true,
    reputation: 4.9,
    successRate: 98.2,
    totalJobsCompleted: 89,
    walletAddress: '0x8765...4321',
    createdAt: '2024-01-05T00:00:00Z',
    rating: 4.9,
    reviews: 15,
  },
  {
    id: '3',
    agentName: 'ImiMagic',
    agentAddress: 'https://api.example.com/web-dev-team',
    description: '全栈Web开发服务，从设计到部署一站式解决方案',
    authorBio: '资深Web开发团队，专注于React和Node.js技术栈',
    agentClassification: 'Web开发',
    tags: ['React', 'Node.js', 'TypeScript', 'AWS'],
    isPrivate: true,
    autoAcceptJobs: true,
    contractType: 'fixed',
    isActive: true,
    reputation: 4.7,
    successRate: 92.1,
    totalJobsCompleted: 156,
    walletAddress: '0xabcd...efgh',
    createdAt: '2024-01-10T00:00:00Z',
    rating: 4.7,
    reviews: 23,
  },
];

// Demo Job数据
export const demoJobs: Job[] = [
  {
    id: '1',
    jobTitle: 'Cartoon Illustration of a Playful Kitten in Garden',
    category: 'Visual Designer',
    description: 'A cute little kitten frolicking in a sunny garden, in a cartoon style.',
    deliverables: '完整的聊天机器人代码、API文档、部署指南',
    budget: { min: 50, max: 50 },
    maxBudget: 50,
    deadline: '2024-07-18T23:59:59',
    paymentType: 'fixed',
    priority: 'medium',
    skillLevel: 'intermediate',
    tags: ['Image', 'Fun'],
    status: 'OPEN',
    autoAssign: true,
    allowBidding: true,
    allowParallelExecution: false,
    escrowEnabled: true,
    isPublic: true,
    walletAddress: '0x3301...1c53',
    createdAt: '2024-07-01T00:00:00Z',
    applications: 0,
    assignments: 0,
  },
  {
    id: '2',
    jobTitle: '数据分析报告',
    category: '数据分析',
    description: '分析用户行为数据，生成详细的用户画像和营销建议报告',
    deliverables: '数据分析报告、可视化图表、营销建议',
    budget: 3.0,
    maxBudget: 3.0,
    deadline: '2024-01-25T23:59:59',
    paymentType: 'result',
    priority: 'medium',
    skillLevel: 'intermediate',
    tags: ['数据分析', '用户画像', 'SQL', 'Tableau'],
    status: 'COMPLETED',
    autoAssign: true,
    allowBidding: false,
    allowParallelExecution: false,
    escrowEnabled: true,
    isPublic: true,
    walletAddress: '0x8765...4321',
    createdAt: '2024-01-05T00:00:00Z',
    applications: 3,
    assignments: 1,
  },
  {
    id: '3',
    jobTitle: 'Web应用开发',
    category: 'Web开发',
    description: '开发一个现代化的Web应用，包含用户认证、数据管理和响应式设计',
    deliverables: '完整的Web应用、源代码、部署文档',
    budget: { min: 8.0, max: 15.0 },
    maxBudget: 15.0,
    deadline: '2024-03-01T23:59:59',
    paymentType: 'milestone',
    priority: 'high',
    skillLevel: 'expert',
    tags: ['React', 'Node.js', 'TypeScript', 'AWS'],
    status: 'OPEN',
    autoAssign: false,
    allowBidding: true,
    allowParallelExecution: true,
    escrowEnabled: true,
    isPublic: false,
    walletAddress: '0xabcd...efgh',
    createdAt: '2024-01-15T00:00:00Z',
    applications: 5,
    assignments: 0,
  },
];

// Demo分类数据
export const demoCategories: Category[] = [
  { id: '1', title: 'Personal Assistant' },
  { id: '2', title: 'Visual Designer' },
  { id: '3', title: 'Marketing Expert' },
  { id: '4', title: 'Biotech Analyst' },
  { id: '5', title: 'Financial Analyst' },
  { id: '6', title: 'Mathematician' },
  { id: '7', title: 'Prediction Market Analyst' },
  { id: '8', title: 'Software' },
  { id: '9', title: 'AI开发' },
  { id: '10', title: 'Web开发' },
  { id: '11', title: '数据分析' },
  { id: '12', title: '设计' },
  { id: '13', title: '写作' },
];

// Demo任务分发Agent数据
export const demoJobDistributionAgents: JobDistributionAgent[] = [
  {
    id: '1',
    agentId: 'agent1',
    agentName: 'PollyArt',
    workStatus: 'ASSIGNED',
    executionResult: '',
    startedAt: '2024-07-01T10:00:00',
    completedAt: '',
    progress: 0,
    errorMessage: '',
    executionTimeMs: 0,
    retryCount: 0,
    rating: 0,
    successRate: 0,
  },
  {
    id: '2',
    agentId: 'agent2',
    agentName: 'DalliCraft',
    workStatus: 'ASSIGNED',
    executionResult: '',
    startedAt: '2024-07-01T09:30:00',
    completedAt: '',
    progress: 0,
    errorMessage: '',
    executionTimeMs: 0,
    retryCount: 0,
    rating: 0,
    successRate: 0,
  },
  {
    id: '3',
    agentId: 'agent3',
    agentName: 'ImiMagic',
    workStatus: 'WORKING',
    executionResult: '',
    startedAt: '2024-07-01T11:00:00',
    completedAt: '',
    progress: 35,
    errorMessage: '',
    executionTimeMs: 45000,
    retryCount: 0,
    rating: 0,
    successRate: 0,
  },
];

// Demo仪表板统计数据
export const demoDashboardStats: DashboardStats = {
  totalAgents: 156,
  activeAgents: 142,
  totalJobs: 89,
  completedJobs: 67,
  totalCategories: 12,
  totalEarnings: 245.8,
  averageJobCompletionTime: 2.3,
  successRate: 94.2,
  publishedAgents: 0,
  activeContracts: 0,
  inProgressJobs: 0,
  disputes: 2,
};

// Demo最近任务数据
export const demoRecentJobs = [
  {
    id: '1',
    title: 'Cartoon Illustration of a Playful Kitten in Garden',
    status: 'open',
    budget: 50,
    completionTime: '-',
  },
  {
    id: '2',
    title: '数据分析报告',
    status: 'completed',
    budget: 3.0,
    completionTime: '2.1天',
  },
  {
    id: '3',
    title: 'Web应用开发',
    status: 'open',
    budget: 12.0,
    completionTime: '-',
  },
];

// Demo热门Agent数据
export const demoRecentAgents = [
  {
    id: '1',
    name: 'PollyArt',
    reputation: 0,
    jobsCompleted: 0,
    category: 'Visual Designer',
  },
  {
    id: '2',
    name: 'DalliCraft',
    reputation: 4.9,
    jobsCompleted: 89,
    category: '数据分析',
  },
  {
    id: '3',
    name: 'ImiMagic',
    reputation: 4.7,
    jobsCompleted: 156,
    category: 'Web开发',
  },
];

// 状态映射函数
export const getStatusColor = (status: string) => {
  switch (status) {
    case 'OPEN':
    case 'open':
      return 'bg-blue-100 text-blue-800';
    case 'DISTRIBUTED':
      return 'bg-yellow-100 text-yellow-800';
    case 'IN_PROGRESS':
    case 'in_progress':
      return 'bg-green-100 text-green-800';
    case 'COMPLETED':
    case 'completed':
      return 'bg-gray-100 text-gray-800';
    case 'CANCELLED':
      return 'bg-red-100 text-red-800';
    case 'EXPIRED':
      return 'bg-orange-100 text-orange-800';
    case 'ASSIGNED':
      return 'bg-yellow-100 text-yellow-800';
    case 'WORKING':
      return 'bg-blue-100 text-blue-800';
    case 'FAILED':
      return 'bg-red-100 text-red-800';
    case 'TIMEOUT':
      return 'bg-orange-100 text-orange-800';
    default:
      return 'bg-gray-100 text-gray-800';
  }
};

export const getStatusText = (status: string) => {
  switch (status) {
    case 'OPEN':
    case 'open':
      return 'Open';
    case 'DISTRIBUTED':
      return '已分发';
    case 'IN_PROGRESS':
    case 'in_progress':
      return 'In Progress';
    case 'COMPLETED':
    case 'completed':
      return 'Completed';
    case 'CANCELLED':
      return '已取消';
    case 'EXPIRED':
      return '已过期';
    case 'ASSIGNED':
      return 'Assigned';
    case 'WORKING':
      return 'Working';
    case 'FAILED':
      return '失败';
    case 'TIMEOUT':
      return '超时';
    default:
      return status;
  }
};

export const getPriorityColor = (priority: string) => {
  switch (priority) {
    case 'low':
      return 'bg-gray-100 text-gray-800';
    case 'medium':
      return 'bg-blue-100 text-blue-800';
    case 'high':
      return 'bg-orange-100 text-orange-800';
    case 'urgent':
      return 'bg-red-100 text-red-800';
    default:
      return 'bg-gray-100 text-gray-800';
  }
};

export const getPriorityText = (priority: string) => {
  switch (priority) {
    case 'low':
      return 'Low';
    case 'medium':
      return 'Medium';
    case 'high':
      return 'High';
    case 'urgent':
      return 'Urgent';
    default:
      return priority;
  }
};

export const formatBudget = (budget: { min: number; max: number } | number) => {
  if (typeof budget === 'number') {
    return `$${budget} USDT`;
  } else {
    return `$${budget.min} - $${budget.max} USDT`;
  }
}; 